package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     *
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 选择按用户名计数
     *
     * @param username 用户名
     * @return {@link Integer}
     */
    Integer selectCountByUserName(String username);

    /**
     * 添加员工
     *
     * @param employee 员工
     */
    @AutoFill(OperationType.INSERT)
    void addEmployee(Employee employee);

    /**
     * 按名称查询员工页面
     *
     * @param name 姓名
     * @return {@link List}<{@link Employee}>
     */
    List<Employee> pageQueryEmployeeByName(String name);

    /**
     * 按员工获取emp
     *
     * @param employee 员工
     * @return {@link Employee}
     */
    Employee getEmpByEmployee(Employee employee);

    /**
     * 按员工更新emp
     *
     * @param employee 员工
     */
    @AutoFill(OperationType.UPDATE)
    void updateEmpByEmployeeId(Employee employee);

    /**
     * 选择按用户名非自身计数
     *
     * @param id       id
     * @param username 用户名
     * @return {@link Integer}
     */
    Integer selectCountByUserNameNotSelf(Long id, String username);
}
